<?php

namespace app\admin\model;

use think\Model;

class Goods extends Model
{   

    //根据一级分类取出商品
    public function getAll1($value){
        $user = Goods::where('type1_id',$value)->select();
        
        foreach ($user as $v){
            $goods[] = $v->toArray();
        }
        if(isset($goods)){
            return  $goods;
        }else{
            return '';
        } 
    }
    //根据二级分类取出商品
    public function getAll2($value){
        $user = Goods::where('type2_id',$value)->select();
        foreach ($user as $v){
            $goods[] = $v->toArray();
        }
        if(isset($goods)){
            return  $goods;
        }else{
            return '';
        }
    }
    //根据三级分类取出商品
    public function getAll3($value){
        $user = Goods::where('type3_id',$value)->select();
        foreach ($user as $v){
            $goods[] = $v->toArray();
        }
        if(isset($goods)){
            return  $goods;
        }else{
            return '';
        }
    }
    //取出所有商品
    public function getAll(){
        $user = Goods::select();
        foreach($user as $v){
            $goods[] = $v->toArray();
        }
        if(isset($goods)){
            return  $goods;
        }else{
            return '';
        }

    }
}
